package com.hd123.rumba.gwt.widget2.client.hotkey;

import java.util.HashMap;
import java.util.Map;

/**
 * 键值常量，可代替{@link com.google.gwt.event.dom.client.KeyCodes} 。
 * <p>
 * 资料来源： <a href=
 * "https://developer.mozilla.org/en/DOM/Event/UIEvent/KeyEvent"
 * >https://developer.mozilla.org/en/DOM/Event/UIEvent/
 * KeyEvent</a>
 * 
 * @author LiQi
 * 
 */
public class RKey {

  public static final int KEY_CODE_CANCEL = 3;
  public static final String KEY_NAME_CANCEL = "Cancel";

  public static final int KEY_CODE_HELP = 6;
  public static final String KEY_NAME_HELP = "Help";

  public static final int KEY_CODE_BACKSPACE = 8;
  public static final String KEY_NAME_BACKSPACE = "Backspace";

  public static final int KEY_CODE_TAB = 9;
  public static final String KEY_NAME_TAB = "Tab";

  public static final int KEY_CODE_CLEAR = 12;
  public static final String KEY_NAME_CLEAR = "Clear";

  public static final int KEY_CODE_ENTER = 13;
  public static final String KEY_NAME_ENTER = "Enter";

  public static final int KEY_CODE_SHIFT = 16;
  public static final String KEY_NAME_SHIFT = "Shift";

  public static final int KEY_CODE_CTRL = 17;
  public static final String KEY_NAME_CTRL = "Ctrl";

  public static final int KEY_CODE_ALT = 18;
  public static final String KEY_NAME_ALT = "Alt";

  public static final int KEY_CODE_PAUSE = 19;
  public static final String KEY_NAME_PAUSE = "Pause";

  public static final int KEY_CODE_CAPS_LOCK = 20;
  public static final String KEY_NAME_CAPS_LOCK = "Caps_lock";

  public static final int KEY_CODE_ESCAPE = 27;
  public static final String KEY_NAME_ESCAPE = "Escape";

  public static final int KEY_CODE_SPACE = 32;
  public static final String KEY_NAME_SPACE = "Space";

  public static final int KEY_CODE_PAGEUP = 33;
  public static final String KEY_NAME_PAGEUP = "Pageup";

  public static final int KEY_CODE_PAGEDOWN = 34;
  public static final String KEY_NAME_PAGEDOWN = "Pagedown";

  public static final int KEY_CODE_END = 35;
  public static final String KEY_NAME_END = "End";

  public static final int KEY_CODE_HOME = 36;
  public static final String KEY_NAME_HOME = "Home";

  public static final int KEY_CODE_LEFT = 37;
  public static final String KEY_NAME_LEFT = "Left";

  public static final int KEY_CODE_UP = 38;
  public static final String KEY_NAME_UP = "Up";

  public static final int KEY_CODE_RIGHT = 39;
  public static final String KEY_NAME_RIGHT = "Right";

  public static final int KEY_CODE_DOWN = 40;
  public static final String KEY_NAME_DOWN = "Down";

  public static final int KEY_CODE_PRINTSCREEN = 44;
  public static final String KEY_NAME_PRINTSCREEN = "Printscreen";

  public static final int KEY_CODE_INSERT = 45;
  public static final String KEY_NAME_INSERT = "Insert";

  public static final int KEY_CODE_DELETE = 46;
  public static final String KEY_NAME_DELETE = "Delete";

  public static final int KEY_CODE_0 = 48;
  public static final String KEY_NAME_0 = "0";

  public static final int KEY_CODE_1 = 49;
  public static final String KEY_NAME_1 = "1";

  public static final int KEY_CODE_2 = 50;
  public static final String KEY_NAME_2 = "2";

  public static final int KEY_CODE_3 = 51;
  public static final String KEY_NAME_3 = "3";

  public static final int KEY_CODE_4 = 52;
  public static final String KEY_NAME_4 = "4";

  public static final int KEY_CODE_5 = 53;
  public static final String KEY_NAME_5 = "5";

  public static final int KEY_CODE_6 = 54;
  public static final String KEY_NAME_6 = "6";

  public static final int KEY_CODE_7 = 55;
  public static final String KEY_NAME_7 = "7";

  public static final int KEY_CODE_8 = 56;
  public static final String KEY_NAME_8 = "8";

  public static final int KEY_CODE_9 = 57;
  public static final String KEY_NAME_9 = "9";

  public static final int KEY_CODE_SEMICOLON = 59;
  public static final String KEY_NAME_SEMICOLON = ";";

  public static final int KEY_CODE_EQUALS = 61;
  public static final String KEY_NAME_EQUALS = "=";

  public static final int KEY_CODE_A = 65;
  public static final String KEY_NAME_A = "A";

  public static final int KEY_CODE_B = 66;
  public static final String KEY_NAME_B = "B";

  public static final int KEY_CODE_C = 67;
  public static final String KEY_NAME_C = "C";

  public static final int KEY_CODE_D = 68;
  public static final String KEY_NAME_D = "D";

  public static final int KEY_CODE_E = 69;
  public static final String KEY_NAME_E = "E";

  public static final int KEY_CODE_F = 70;
  public static final String KEY_NAME_F = "F";

  public static final int KEY_CODE_G = 71;
  public static final String KEY_NAME_G = "G";

  public static final int KEY_CODE_H = 72;
  public static final String KEY_NAME_H = "H";

  public static final int KEY_CODE_I = 73;
  public static final String KEY_NAME_I = "I";

  public static final int KEY_CODE_J = 74;
  public static final String KEY_NAME_J = "J";

  public static final int KEY_CODE_K = 75;
  public static final String KEY_NAME_K = "K";

  public static final int KEY_CODE_L = 76;
  public static final String KEY_NAME_L = "L";

  public static final int KEY_CODE_M = 77;
  public static final String KEY_NAME_M = "M";

  public static final int KEY_CODE_N = 78;
  public static final String KEY_NAME_N = "N";

  public static final int KEY_CODE_O = 79;
  public static final String KEY_NAME_O = "O";

  public static final int KEY_CODE_P = 80;
  public static final String KEY_NAME_P = "P";

  public static final int KEY_CODE_Q = 81;
  public static final String KEY_NAME_Q = "Q";

  public static final int KEY_CODE_R = 82;
  public static final String KEY_NAME_R = "R";

  public static final int KEY_CODE_S = 83;
  public static final String KEY_NAME_S = "S";

  public static final int KEY_CODE_T = 84;
  public static final String KEY_NAME_T = "T";

  public static final int KEY_CODE_U = 85;
  public static final String KEY_NAME_U = "U";

  public static final int KEY_CODE_V = 86;
  public static final String KEY_NAME_V = "V";

  public static final int KEY_CODE_W = 87;
  public static final String KEY_NAME_W = "W";

  public static final int KEY_CODE_X = 88;
  public static final String KEY_NAME_X = "X";

  public static final int KEY_CODE_Y = 89;
  public static final String KEY_NAME_Y = "Y";

  public static final int KEY_CODE_Z = 90;
  public static final String KEY_NAME_Z = "Z";

  public static final int KEY_CODE_CONTEXT_MENU = 93;
  public static final String KEY_NAME_CONTEXT_MENU = "Context_menu";

  public static final int KEY_CODE_NUMPAD0 = 96;
  public static final String KEY_NAME_NUMPAD0 = "Numpad0";

  public static final int KEY_CODE_NUMPAD1 = 97;
  public static final String KEY_NAME_NUMPAD1 = "Numpad1";

  public static final int KEY_CODE_NUMPAD2 = 98;
  public static final String KEY_NAME_NUMPAD2 = "Numpad2";

  public static final int KEY_CODE_NUMPAD3 = 99;
  public static final String KEY_NAME_NUMPAD3 = "Numpad3";

  public static final int KEY_CODE_NUMPAD4 = 100;
  public static final String KEY_NAME_NUMPAD4 = "Numpad4";

  public static final int KEY_CODE_NUMPAD5 = 101;
  public static final String KEY_NAME_NUMPAD5 = "Numpad5";

  public static final int KEY_CODE_NUMPAD6 = 102;
  public static final String KEY_NAME_NUMPAD6 = "Numpad6";

  public static final int KEY_CODE_NUMPAD7 = 103;
  public static final String KEY_NAME_NUMPAD7 = "Numpad7";

  public static final int KEY_CODE_NUMPAD8 = 104;
  public static final String KEY_NAME_NUMPAD8 = "Numpad8";

  public static final int KEY_CODE_NUMPAD9 = 105;
  public static final String KEY_NAME_NUMPAD9 = "Numpad9";

  public static final int KEY_CODE_MULTIPLY = 106;
  public static final String KEY_NAME_MULTIPLY = "Numpad*";

  public static final int KEY_CODE_ADD = 107;
  public static final String KEY_NAME_ADD = "Numpad+";

  public static final int KEY_CODE_SEPARATOR = 108;
  public static final String KEY_NAME_SEPARATOR = "Separator";

  public static final int KEY_CODE_SUBTRACT = 109;
  public static final String KEY_NAME_SUBTRACT = "Numpad-";

  public static final int KEY_CODE_DECIMAL = 110;
  public static final String KEY_NAME_DECIMAL = "Numpad.";

  public static final int KEY_CODE_DIVIDE = 111;
  public static final String KEY_NAME_DIVIDE = "Numpad/";

  public static final int KEY_CODE_F1 = 112;
  public static final String KEY_NAME_F1 = "F1";

  public static final int KEY_CODE_F2 = 113;
  public static final String KEY_NAME_F2 = "F2";

  public static final int KEY_CODE_F3 = 114;
  public static final String KEY_NAME_F3 = "F3";

  public static final int KEY_CODE_F4 = 115;
  public static final String KEY_NAME_F4 = "F4";

  public static final int KEY_CODE_F5 = 116;
  public static final String KEY_NAME_F5 = "F5";

  public static final int KEY_CODE_F6 = 117;
  public static final String KEY_NAME_F6 = "F6";

  public static final int KEY_CODE_F7 = 118;
  public static final String KEY_NAME_F7 = "F7";

  public static final int KEY_CODE_F8 = 119;
  public static final String KEY_NAME_F8 = "F8";

  public static final int KEY_CODE_F9 = 120;
  public static final String KEY_NAME_F9 = "F9";

  public static final int KEY_CODE_F10 = 121;
  public static final String KEY_NAME_F10 = "F10";

  public static final int KEY_CODE_F11 = 122;
  public static final String KEY_NAME_F11 = "F11";

  public static final int KEY_CODE_F12 = 123;
  public static final String KEY_NAME_F12 = "F12";

  public static final int KEY_CODE_F13 = 124;
  public static final String KEY_NAME_F13 = "F13";

  public static final int KEY_CODE_F14 = 125;
  public static final String KEY_NAME_F14 = "F14";

  public static final int KEY_CODE_F15 = 126;
  public static final String KEY_NAME_F15 = "F15";

  public static final int KEY_CODE_F16 = 127;
  public static final String KEY_NAME_F16 = "F16";

  public static final int KEY_CODE_F17 = 128;
  public static final String KEY_NAME_F17 = "F17";

  public static final int KEY_CODE_F18 = 129;
  public static final String KEY_NAME_F18 = "F18";

  public static final int KEY_CODE_F19 = 130;
  public static final String KEY_NAME_F19 = "F19";

  public static final int KEY_CODE_F20 = 131;
  public static final String KEY_NAME_F20 = "F20";

  public static final int KEY_CODE_F21 = 132;
  public static final String KEY_NAME_F21 = "F21";

  public static final int KEY_CODE_F22 = 133;
  public static final String KEY_NAME_F22 = "F22";

  public static final int KEY_CODE_F23 = 134;
  public static final String KEY_NAME_F23 = "F23";

  public static final int KEY_CODE_F24 = 135;
  public static final String KEY_NAME_F24 = "F24";

  public static final int KEY_CODE_NUM_LOCK = 144;
  public static final String KEY_NAME_NUM_LOCK = "Num_lock";

  public static final int KEY_CODE_SCROLL_LOCK = 145;
  public static final String KEY_NAME_SCROLL_LOCK = "Scroll_lock";

  public static final int KEY_CODE_COMMA = 188;
  public static final String KEY_NAME_COMMA = ",";

  public static final int KEY_CODE_PERIOD = 190;
  public static final String KEY_NAME_PERIOD = ".";

  public static final int KEY_CODE_SLASH = 191;
  public static final String KEY_NAME_SLASH = "/";

  public static final int KEY_CODE_BACK_QUOTE = 192;
  public static final String KEY_NAME_BACK_QUOTE = "`";

  public static final int KEY_CODE_OPEN_BRACKET = 219;
  public static final String KEY_NAME_OPEN_BRACKET = "[";

  public static final int KEY_CODE_BACK_SLASH = 220;
  public static final String KEY_NAME_BACK_SLASH = "\\";

  public static final int KEY_CODE_CLOSE_BRACKET = 221;
  public static final String KEY_NAME_CLOSE_BRACKET = "]";

  public static final int KEY_CODE_QUOTE = 222;
  public static final String KEY_NAME_QUOTE = "'";

  public static final int KEY_CODE_META = 224;
  public static final String KEY_NAME_META = "Meta";

  /**
   * 根据键值查询键名称
   * 
   * @param keyCode
   * @return
   */
  public static String getKeyName(int keyCode) {
    if (map == null)
      initMap();
    return map.get(new Integer(keyCode));
  }

  /** 键值和名称映射表 */
  private static Map<Integer, String> map;

  /**
   * 初始化映射表
   * 
   */
  private static void initMap() {
    map = new HashMap();
    map.put(new Integer(KEY_CODE_CANCEL), KEY_NAME_CANCEL);
    map.put(new Integer(KEY_CODE_HELP), KEY_NAME_HELP);
    map.put(new Integer(KEY_CODE_BACKSPACE), KEY_NAME_BACKSPACE);
    map.put(new Integer(KEY_CODE_TAB), KEY_NAME_TAB);
    map.put(new Integer(KEY_CODE_CLEAR), KEY_NAME_CLEAR);
    map.put(new Integer(KEY_CODE_ENTER), KEY_NAME_ENTER);
    map.put(new Integer(KEY_CODE_SHIFT), KEY_NAME_SHIFT);
    map.put(new Integer(KEY_CODE_CTRL), KEY_NAME_CTRL);
    map.put(new Integer(KEY_CODE_ALT), KEY_NAME_ALT);
    map.put(new Integer(KEY_CODE_PAUSE), KEY_NAME_PAUSE);
    map.put(new Integer(KEY_CODE_CAPS_LOCK), KEY_NAME_CAPS_LOCK);
    map.put(new Integer(KEY_CODE_ESCAPE), KEY_NAME_ESCAPE);
    map.put(new Integer(KEY_CODE_SPACE), KEY_NAME_SPACE);
    map.put(new Integer(KEY_CODE_PAGEUP), KEY_NAME_PAGEUP);
    map.put(new Integer(KEY_CODE_PAGEDOWN), KEY_NAME_PAGEDOWN);
    map.put(new Integer(KEY_CODE_END), KEY_NAME_END);
    map.put(new Integer(KEY_CODE_HOME), KEY_NAME_HOME);
    map.put(new Integer(KEY_CODE_LEFT), KEY_NAME_LEFT);
    map.put(new Integer(KEY_CODE_UP), KEY_NAME_UP);
    map.put(new Integer(KEY_CODE_RIGHT), KEY_NAME_RIGHT);
    map.put(new Integer(KEY_CODE_DOWN), KEY_NAME_DOWN);
    map.put(new Integer(KEY_CODE_PRINTSCREEN), KEY_NAME_PRINTSCREEN);
    map.put(new Integer(KEY_CODE_INSERT), KEY_NAME_INSERT);
    map.put(new Integer(KEY_CODE_DELETE), KEY_NAME_DELETE);
    map.put(new Integer(KEY_CODE_0), KEY_NAME_0);
    map.put(new Integer(KEY_CODE_1), KEY_NAME_1);
    map.put(new Integer(KEY_CODE_2), KEY_NAME_2);
    map.put(new Integer(KEY_CODE_3), KEY_NAME_3);
    map.put(new Integer(KEY_CODE_4), KEY_NAME_4);
    map.put(new Integer(KEY_CODE_5), KEY_NAME_5);
    map.put(new Integer(KEY_CODE_6), KEY_NAME_6);
    map.put(new Integer(KEY_CODE_7), KEY_NAME_7);
    map.put(new Integer(KEY_CODE_8), KEY_NAME_8);
    map.put(new Integer(KEY_CODE_9), KEY_NAME_9);
    map.put(new Integer(KEY_CODE_SEMICOLON), KEY_NAME_SEMICOLON);
    map.put(new Integer(KEY_CODE_EQUALS), KEY_NAME_EQUALS);
    map.put(new Integer(KEY_CODE_A), KEY_NAME_A);
    map.put(new Integer(KEY_CODE_B), KEY_NAME_B);
    map.put(new Integer(KEY_CODE_C), KEY_NAME_C);
    map.put(new Integer(KEY_CODE_D), KEY_NAME_D);
    map.put(new Integer(KEY_CODE_E), KEY_NAME_E);
    map.put(new Integer(KEY_CODE_F), KEY_NAME_F);
    map.put(new Integer(KEY_CODE_G), KEY_NAME_G);
    map.put(new Integer(KEY_CODE_H), KEY_NAME_H);
    map.put(new Integer(KEY_CODE_I), KEY_NAME_I);
    map.put(new Integer(KEY_CODE_J), KEY_NAME_J);
    map.put(new Integer(KEY_CODE_K), KEY_NAME_K);
    map.put(new Integer(KEY_CODE_L), KEY_NAME_L);
    map.put(new Integer(KEY_CODE_M), KEY_NAME_M);
    map.put(new Integer(KEY_CODE_N), KEY_NAME_N);
    map.put(new Integer(KEY_CODE_O), KEY_NAME_O);
    map.put(new Integer(KEY_CODE_P), KEY_NAME_P);
    map.put(new Integer(KEY_CODE_Q), KEY_NAME_Q);
    map.put(new Integer(KEY_CODE_R), KEY_NAME_R);
    map.put(new Integer(KEY_CODE_S), KEY_NAME_S);
    map.put(new Integer(KEY_CODE_T), KEY_NAME_T);
    map.put(new Integer(KEY_CODE_U), KEY_NAME_U);
    map.put(new Integer(KEY_CODE_V), KEY_NAME_V);
    map.put(new Integer(KEY_CODE_W), KEY_NAME_W);
    map.put(new Integer(KEY_CODE_X), KEY_NAME_X);
    map.put(new Integer(KEY_CODE_Y), KEY_NAME_Y);
    map.put(new Integer(KEY_CODE_Z), KEY_NAME_Z);
    map.put(new Integer(KEY_CODE_CONTEXT_MENU), KEY_NAME_CONTEXT_MENU);
    map.put(new Integer(KEY_CODE_NUMPAD0), KEY_NAME_NUMPAD0);
    map.put(new Integer(KEY_CODE_NUMPAD1), KEY_NAME_NUMPAD1);
    map.put(new Integer(KEY_CODE_NUMPAD2), KEY_NAME_NUMPAD2);
    map.put(new Integer(KEY_CODE_NUMPAD3), KEY_NAME_NUMPAD3);
    map.put(new Integer(KEY_CODE_NUMPAD4), KEY_NAME_NUMPAD4);
    map.put(new Integer(KEY_CODE_NUMPAD5), KEY_NAME_NUMPAD5);
    map.put(new Integer(KEY_CODE_NUMPAD6), KEY_NAME_NUMPAD6);
    map.put(new Integer(KEY_CODE_NUMPAD7), KEY_NAME_NUMPAD7);
    map.put(new Integer(KEY_CODE_NUMPAD8), KEY_NAME_NUMPAD8);
    map.put(new Integer(KEY_CODE_NUMPAD9), KEY_NAME_NUMPAD9);
    map.put(new Integer(KEY_CODE_MULTIPLY), KEY_NAME_MULTIPLY);
    map.put(new Integer(KEY_CODE_ADD), KEY_NAME_ADD);
    map.put(new Integer(KEY_CODE_SEPARATOR), KEY_NAME_SEPARATOR);
    map.put(new Integer(KEY_CODE_SUBTRACT), KEY_NAME_SUBTRACT);
    map.put(new Integer(KEY_CODE_DECIMAL), KEY_NAME_DECIMAL);
    map.put(new Integer(KEY_CODE_DIVIDE), KEY_NAME_DIVIDE);
    map.put(new Integer(KEY_CODE_F1), KEY_NAME_F1);
    map.put(new Integer(KEY_CODE_F2), KEY_NAME_F2);
    map.put(new Integer(KEY_CODE_F3), KEY_NAME_F3);
    map.put(new Integer(KEY_CODE_F4), KEY_NAME_F4);
    map.put(new Integer(KEY_CODE_F5), KEY_NAME_F5);
    map.put(new Integer(KEY_CODE_F6), KEY_NAME_F6);
    map.put(new Integer(KEY_CODE_F7), KEY_NAME_F7);
    map.put(new Integer(KEY_CODE_F8), KEY_NAME_F8);
    map.put(new Integer(KEY_CODE_F9), KEY_NAME_F9);
    map.put(new Integer(KEY_CODE_F10), KEY_NAME_F10);
    map.put(new Integer(KEY_CODE_F11), KEY_NAME_F11);
    map.put(new Integer(KEY_CODE_F12), KEY_NAME_F12);
    map.put(new Integer(KEY_CODE_F13), KEY_NAME_F13);
    map.put(new Integer(KEY_CODE_F14), KEY_NAME_F14);
    map.put(new Integer(KEY_CODE_F15), KEY_NAME_F15);
    map.put(new Integer(KEY_CODE_F16), KEY_NAME_F16);
    map.put(new Integer(KEY_CODE_F17), KEY_NAME_F17);
    map.put(new Integer(KEY_CODE_F18), KEY_NAME_F18);
    map.put(new Integer(KEY_CODE_F19), KEY_NAME_F19);
    map.put(new Integer(KEY_CODE_F20), KEY_NAME_F20);
    map.put(new Integer(KEY_CODE_F21), KEY_NAME_F21);
    map.put(new Integer(KEY_CODE_F22), KEY_NAME_F22);
    map.put(new Integer(KEY_CODE_F23), KEY_NAME_F23);
    map.put(new Integer(KEY_CODE_F24), KEY_NAME_F24);
    map.put(new Integer(KEY_CODE_NUM_LOCK), KEY_NAME_NUM_LOCK);
    map.put(new Integer(KEY_CODE_SCROLL_LOCK), KEY_NAME_SCROLL_LOCK);
    map.put(new Integer(KEY_CODE_COMMA), KEY_NAME_COMMA);
    map.put(new Integer(KEY_CODE_PERIOD), KEY_NAME_PERIOD);
    map.put(new Integer(KEY_CODE_SLASH), KEY_NAME_SLASH);
    map.put(new Integer(KEY_CODE_BACK_QUOTE), KEY_NAME_BACK_QUOTE);
    map.put(new Integer(KEY_CODE_OPEN_BRACKET), KEY_NAME_OPEN_BRACKET);
    map.put(new Integer(KEY_CODE_BACK_SLASH), KEY_NAME_BACK_SLASH);
    map.put(new Integer(KEY_CODE_CLOSE_BRACKET), KEY_NAME_CLOSE_BRACKET);
    map.put(new Integer(KEY_CODE_QUOTE), KEY_NAME_QUOTE);
    map.put(new Integer(KEY_CODE_META), KEY_NAME_META);
  }

  /**
   * 禁止实例化
   */
  private RKey() {
  }
}
